import os
import threading
import requests

header = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.3'
}

pre_target_url = 'https://stickershop.line-scdn.net/stickershop/v1/sticker/{}/android/sticker.png'


def get_from_num(num) -> bool:
    target_url = pre_target_url.format(str(num))
    try:
        pic_data = requests.get(target_url, headers=header)
        with open('./arc/{}.png'.format(str(num)), 'wb+') as pic_file:
            pic_file.write(pic_data.content)
            print('pic_{}.png have been saved!'.format(str(num)))
            pic_data.close()
        return True
    except Exception as ex:
        return False


t1 = 355324774
t2 = 355324805


if __name__ == '__main__':
    if not os.path.exists('arc'):
        os.mkdir('arc')
    for i in range(t1, t2 + 1):
        tr=threading.Thread(target=get_from_num,args=(i,))
        tr.start()



